using Senparc.Weixin.HttpUtility;
using Senparc.Weixin.QY.AdvancedAPIs.OAuth2;
using System;
namespace Senparc.Weixin.QY.AdvancedAPIs
{
	public static class OAuth2Api
	{
		public static string GetCode(string corpId, string redirectUrl, string state, string responseType = "code", string scope = "snsapi_base")
		{
			return string.Format("https://open.weixin.qq.com/connect/oauth2/authorize?appid={0}&redirect_uri={1}&response_type={2}&scope={3}&state={4}#wechat_redirect", new object[]
			{
				corpId,
				redirectUrl,
				responseType,
				scope,
				state
			});
		}
		public static GetUserInfoResult GetUserId(string accessToken, string code)
		{
			string url = string.Format("https://qyapi.weixin.qq.com/cgi-bin/user/getuserinfo?access_token={0}&code={1}", accessToken, code);
			return Get.GetJson<GetUserInfoResult>(url, null);
		}
	}
}
